<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Model\User;

class UserController extends Controller
{
	public function show(User $user){
		$user = User::withCount(['stars','fans','posts'])->find($user->id);

		$posts = $user->posts()->orderBy('created_at','desc')->take(10)->get();

		//获取粉丝的信息
		$suser = User::whereIn('id',$user->fans()->pluck('star_id'))->get();
		//获取关注的信息
		$stars = User::whereIn('id',$user->stars()->pluck('fan_id'))->get();

		return view('user.show');
	}

	
}